﻿
$(function () {
    LedgerShow()
})

var index = 1; 
var size = 100;
var tacount = 0;
function LedgerShow() {
    layui.use(['form', 'table'], function () {
        var table = layui.table;

        var productNo = $("#productNo").val()
        var productName = $("#productName").val()
        var binLocationName = $("#binLocationName").val()
        var batch = $("#batch").val()

        $.ajax({
            url: '../LedgerInfo/LedgerInfoShow',
            type: 'get',
            data: {
                productNo: productNo,
                productName: productName,
                binLocationName: binLocationName,
                batch: batch,
                index: index,
                size: size,
            },
            success: function (res) {
                var list = '';
                var parsedData = JSON.parse(res);
                console.log(parsedData)
                if (parsedData.code === 0) {
                    table.render({
                        elem: ledgerProductList, // 对应 HTML 中表格的 id
                        data: parsedData.data.list, // 绑定获取到的数据
                        toolbar: '#toolbarDemo',
                        defaultToolbar: ['exports'],
                        page: true,
                        limit: 8,
                        limits: [8, 15, 20],
                        cols: [[
                            { field: 'reportlossesId', title: '序号' },
                            { field: 'productNo', title: '产品编号' },
                            { field: 'productName', title: '产品名称' },
                            { field: 'productSpec', title: '产品规格' },
                            { field: 'batch', title: '产品批次' },
                            /*{ field: 'reportNum', title: '类型' },*/
                            { field: 'binLocationName', title: '仓库' },
                            { field: 'wlocator', title: '数量' },
                            { field: 'productSpec', title: '单位' },
                            { field: 'wRepolocator', title: '原库位' },
                            { field: 'createTime', title: '日期'},
                            {
                                field: '', title: '操作', width: 200, templet: function (d) {
                                    return '<a class="layui-btn layui-btn-edit layui-btn-xs" lay-on="test-page-edit" onclick=" editDataFind(' + d.reportlossesId + ')"><i class="layui-icon layui-icon-search"></i>查看</a> ' +
                                        '<a class="layui-btn layui-btn-sm layui-btn-primary" lay-on=s"test-page-edit" onclick="updateData(' + d.reportlossesId + ')"><i class="layui-icon layui-icon-edit"></i>编辑</a> ' +

                                        '<a class="layui-btn layui-btn-danger layui-btn-xs" onclick="reportRangeDel(' + d.reportlossesId + ')"><i class="layui-icon layui-icon-delete"></i>删除</a>' +
                                        '<a class="layui-btn layui-btn-edit layui-btn-xs" onclick="storageaudit(' + d.reportlossesId + ')"><i class="layui-icon layui-icon-share"></i>审核</a>';
                                }
                            }
                        ]]
                    })
                }

                $("#data").html(list);
                tacount = parsedData.data.tacount;
            }
        })


    })
}
